package com.myres.model;

import java.sql.Timestamp;
import java.sql.ResultSet;
import java.util.List;
import java.util.ArrayList;

public class Score {
	public static final String NOTE_DISCOUNT = "消费回馈，谢谢惠顾";
	public static final String NOTE_VISIT = "访问回馈，欢迎访问";
	public static final String NOTE_APPRAISAL = "评价奖励，献言献策";
	public static final String NOTE_CASH = "购买积分，方便实惠";
	public static final String NOTE_REPAY = "积分退还，安全方心";
	public static final String NOTE_PAY = "积分支付，方便实惠";
	public static final String NOTE_OTHER = "其他回馈，惊喜不断";
	public static final String NOTE_REG = "注册回馈，欢迎光临";
	public static final int TYPE_DISCONT = 1;
	public static final int TYPE_VISIT = 2;
	public static final int TYPE_APPRAISAL = 3;
	public static final int TYPE_CASH = 4;
	public static final int TYPE_REPAY = 5;
	public static final int TYPE_PAY = 6;
	public static final int TYPE_OTHER = 7;
	public static final int TYPE_REG = 8;

	private int id;
	private String ono;
	private int score;
	private int uid;
	private User user;
	private Timestamp addTime;
	private String note;
	private int reason;

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getOno() {
		return ono;
	}

	public void setOno(String ono) {
		this.ono = ono;
	}

	public int getScore() {
		return score;
	}

	public void setScore(int score) {
		this.score = score;
	}

	public int getUid() {
		return uid;
	}

	public void setUid(int uid) {
		this.uid = uid;
	}

	public Timestamp getAddTime() {
		return addTime;
	}

	public void setAddTime(Timestamp addTime) {
		this.addTime = addTime;
	}

	public String getNote() {
		return note;
	}

	public void setNote(String note) {
		this.note = note;
	}

	public int getReason() {
		return reason;
	}

	public void setReason(int reason) {
		this.reason = reason;
	}

	public static List<Score> populate(ResultSet rs) {
		if (rs == null)
			return null;
		ArrayList<Score> list = new ArrayList<Score>();
		try {
			while (rs.next()) {
				Score score = new Score();
				score.setId(rs.getInt(1));
				score.setOno(rs.getString(2));
				score.setScore(rs.getInt(3));
				score.setUid(rs.getInt(4));
				score.setAddTime(rs.getTimestamp(5));
				score.setNote(rs.getString(6));
				score.setReason(rs.getInt(7));
				list.add(score);
			}
			return list;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}

	}

}
